<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
<#include "../common/link.ftl"/>
    <script>
        $(function () {
            //编辑页面的数据回显
            $(".btn-input").click(function () {

                //清空表单中的数据
                $("#editForm input").val("");
//                $("#editForm").get(0).reset();
                //获取当前按钮上绑定的数据
                var json = $(this).data("json");
                if (json) {
                    //填充到表单中
                    $("input[name=id]").val(json.id);
                    $("input[name=title]").val(json.title);
                    $("input[name=sn]").val(json.sn);
                    $("input[name=intro]").val(json.intro);
                }
                $("#editModal").modal("show");
            })

            //提交表单
            $(".btn-submit").click(function () {
                //data:后台响应回来的数据: {success:true,errorMsg:""}
                $("#editForm").ajaxSubmit(function (data) {
                    handleMessage(data);
                })
            })
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">


<div class="wrapper">

<#include "../common/navbar.ftl"/>

    <!--菜单回显-->
<#assign currentMenu="systemDictionary"/>

<#include "../common/menu.ftl"/>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典目录管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemDictionary/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="javascript:;" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>标题</th>
                            <th>编码</th>
                            <th>简介</th>
                            <th>操作</th>
                        </tr>
                    <#list pageInfo.list as entity>
                        <tr>
                            <td>${entity_index + 1}</td>
                            <td>${entity.title}</td>
                            <td>${entity.sn}</td>
                            <td>${entity.intro}</td>
                            <td>
                                <a class="btn btn-info btn-xs btn-input" href="javascript:;" data-json='${entity.json}'>
                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                </a>

                                <a href="javascript:;" data-url="/systemDictionary/delete.do?id=${entity.id}"
                                   class="btn btn-danger btn-xs btn-delete">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>

                            </td>
                        </tr>
                    </#list>
                    </table>
                    <!--分页-->
                <#include "../common/page.ftl"/>
                </div>
            </div>
        </section>
    </div>
<#include "../common/footer.ftl"/>
</div>


<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">字典目录编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionary/saveOrUpdate.do" method="post" id="editForm">


                <#--如果取到的值为null或者没有,此时freemarker会报错-->
                    <input type="hidden" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="title" class="col-sm-2 control-label">标题：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入标题" style="width: 300px">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-2 control-label">编码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="sn" name="sn"
                                   placeholder="请输入编码" style="width: 300px">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="intro" class="col-sm-2 control-label">简介：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="intro" name="intro"
                                   placeholder="请输入简介" style="width: 300px">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">戳这关闭</button>
                <button type="button" class="btn btn-primary btn-submit">朕要提交</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
